#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int triangleNumber(int* nums, int numsSize) {
    for (int i = 0; i < numsSize - 1; i++)
    {
        int count = 0;
        for (int j = 0; j < numsSize - 1 - i; j++)
        {
            int tmp;
            if (nums[j] > nums[j + 1])
            {
                tmp = nums[j];
                nums[j] = nums[j + 1];
                nums[j + 1] = tmp;
                count = 1;
            }
        }
        if (count == 0)
            break;
    }
    int ret = 0, n = numsSize;
    for (int i = n - 1; i >= 2; i--)
    {
        int left = 0, right = i - 1;
        while (left < right)
        {
            if (nums[left] + nums[right] > nums[i])
            {
                ret += right - left;
                right--;
            }
            else
                left++;
        }
    }
    return ret;
}
int main()
{
    int arr[10] = { 1,2,3,6,3,2,6,8,1,7 };
    printf("%d",triangleNumber(arr, 10));
	return 0;
}